<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>我的购物车</title>
<link rel="stylesheet" type="text/css"
	href="themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="themes/icon.css">
<link rel="stylesheet" type="text/css" href="themes/color.css">
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="js/easyui-lang-zh_CN.js"></script>
</head>
<script type="text/javascript">
$(function(){
	$('#dg').datagrid({    
	    url:'wdgwcly',    
	    columns:[[ 
	        {field:'ck',title:'确定要买 ',checkbox:true, width:100},
	        {field:'gid',title:'购物车唯一id',width:100},
	        {field:'dname',title:'菜名 ',width:100},    
	        {field:'rprice',title:'总价 ',width:100},
	        {field:'nbu',title:'菜的份数 ',width:100},
	    ]],
	    pagination:false,
	    striped:true,
	    rownumbers:true,
	    toolbar: [{
    	iconCls: 'icon-remove',
		text:'删除',
		handler: function(){
			var sdata = $('#dg').datagrid('getSelections');
			  if(sdata.length!=1){
				  $.messager.show({
						title:'我的消息',
						msg:'请一个一个删除。',
						timeout:100,
						showType:'slide'
					});
				  $('#dg').datagrid('clearChecked');
			  }else{
				  var s=sdata[0];
				var gid=s.gid
			       var url = "scgwc?gid=" + gid;
			        $.ajax({
			            url: url,
			            type: 'post',
			            timeout: 100,

			            Error: function () {
			                alert(Error);
			            },
			            success: function () {
			                window.location.href = url
			                alert("删除成功");
			            }
			        });
				   
			  }
			}
	},'-',{
    	iconCls: 'icon-add',
		text:'提交',
		handler: function(){

			var sdata = $('#dg').datagrid('getSelections');
			  if(sdata.length!=1){
				  $.messager.show({
						title:'我的消息',
						msg:'很不好意思我们只能一个一个下订单 ',
						timeout:100,
						showType:'slide'
					});
				  $('#dg').datagrid('clearChecked');
			  }else{
				  var s=sdata[0];
				var gid=s.gid
			       var url = "tjdd?gid=" + gid;
			        $.ajax({
			            url: url,
			            type: 'post',
			            timeout: 100,

			            Error: function () {
			                alert(Error);
			            },
			            success: function () {
			                window.location.href = url
			                alert("添加订单成功 ");
			            }
			        });
				   
			  }
			
			}
	}
	    ],
		
	})
})

</script>
<body>
${sessionScope.uname}的购物车
<table id="dg">
</table>

</body>
</html>